﻿using daonaite.core.Attribute;
using daonaite.DAL.system;
using daonaite.Model.system.role;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace daonaite.services.system
{
    [AutoLoad]
    public class roleService
    {
        private readonly D_role rolecz;

        public roleService(D_role rolecz)
        {
            this.rolecz = rolecz;
        }

        /// <summary>
        /// 分页查询角色
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<IEnumerable<sys_role>> selectpageAsync(Dto_role data, RefAsync<int> total)
        {
            return await rolecz.selectpageAsync(data, total);
        }

        /// <summary>
        /// 查询所有角色
        /// </summary>
        /// <returns></returns>
        public async Task<IEnumerable<sys_role>> selectall()
        {
            return await rolecz.selectall();
        }

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<int> add(sys_role data)
        {
            return await rolecz.add(data);
        }

        /// <summary>
        /// 根据id获取角色信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<sys_role> getAsync(int id)
        {
            return await rolecz.getAsync(id);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public async Task<int> updateAsync(sys_role data)
        {
            return await rolecz.updateAsync(data);
        }


        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<int> delete(int id)
        {
            return await rolecz.delete(id);
        }
    }
}
